﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace FluentETL.Impl
{
    public class CustomDestination : IDestination
    {
        private Action<IRow> _processRow;
        private Action<IRow> _insertRow;
        private Action<IRow> _updateRow;
        private Action<IRow> _deleteRow;

        public CustomDestination ProcessWith(Action<IRow> action)
        {
            _processRow = action;
            return this;
        }

        public CustomDestination InsertWith(Action<IRow> action)
        {
            _insertRow = action;
            return this;
        }

        public CustomDestination UpdateWith(Action<IRow> action)
        {
            _updateRow = action;
            return this;
        }

        public CustomDestination DeleteWith(Action<IRow> action)
        {
            _deleteRow = action;
            return this;
        }

        void IDestination.InTransformContext(ITransform t, Action action)
        {
            action();
        }

        void IDestination.Process(IRow row)
        {
            _processRow(row);
        }

        void IDestination.Insert(IRow row)
        {
            _insertRow(row);
        }

        void IDestination.Update(IRow row)
        {
            _updateRow(row);
        }

        void IDestination.Delete(IRow row)
        {
            _deleteRow(row);
        }
    }
}
